package cn.wolfcode.p2p.base.domain;

import cn.wolfcode.p2p.util.Constant;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;

@Setter
@Getter
public class Account extends BaseDomain {
    /**
     * 交易密码
     */
    private String tradePassword;
    /**
     * 可用余额
     */
    private BigDecimal usableAmount = Constant.ZERO;
    /**
     * 冻结资金
     */
    private BigDecimal freezedAmount = Constant.ZERO;
    /**
     * 版本号
     */
    private Integer version = 0;
    /**
     * 代收利息
     */
    private BigDecimal unReceiveInterest = Constant.ZERO;
    /**
     * 代收本金
     */
    private BigDecimal unReceivePrincipal = Constant.ZERO;
    /**
     * 待还本息
     */
    private BigDecimal unReturnAmount = Constant.ZERO;
    /**
     * 剩余授信额度
     */
    private BigDecimal remainBorrowLimit = Constant.DEFAULT_BORROW_LIMIT;

    /**
     * 授信额度
     */
    private BigDecimal borrowLimit = Constant.DEFAULT_BORROW_LIMIT;

    /**
     * 用户总额
     */

    public BigDecimal getTotalAmount(){
        return usableAmount.add(freezedAmount).add(unReceivePrincipal);
    }

    /**
     * 添加可用余额
     */
    public void addUsableAmount(BigDecimal usableAmount){
        BigDecimal temp = this.usableAmount.add(usableAmount);
        this.usableAmount = temp;

    }
    /**
     * 减少可用余额
     */
    public void subtractUsableAmount(BigDecimal usableAmount){
        BigDecimal temp = this.usableAmount.subtract(usableAmount);
        this.usableAmount = temp;

    }
    /**
     * 添加冻结资金
     */
    public void addFreezedAmount(BigDecimal freezedAmount){
        BigDecimal temp = this.freezedAmount.add(freezedAmount);
        this.freezedAmount = temp;

    }
    /**
     * 减少冻结资金
     */
    public void subtractFreezedAmount(BigDecimal freezedAmount){
        BigDecimal temp = this.freezedAmount.subtract(freezedAmount);
        this.freezedAmount = temp;

    }

}
